﻿
<template>
<div class="card-fill layout-padding">
<el-card shadow="hover" class="layout-padding-auto" >
  <el-form ref="formRefProdArchiveData" :model="stateProdArchiveData.vmModel" label-width="100px">
    <div style="margin-bottom:10px;">{{$t('message.autotrans.SysBatchEditConfirm')}}</div>
    <el-row>
      <el-col :xs="24" :lg="12" class="mb20">
      <el-form-item ref="LinkedVM_ArchiveIdId_FormItem" prop="LinkedVM.ArchiveIdId" :label="$t('message.autotrans._Model_ProdArchiveData_ArchiveId')">
          <el-select v-model="stateProdArchiveData.vmModel.LinkedVM.ArchiveIdId" clearable>
             <el-option v-for="item in stateProdArchiveData.AllArchiveIds" :key="item.Value" :value="item.Value" :label="item.Text"></el-option>
          </el-select>
      </el-form-item>

      </el-col>
      <el-col :xs="24" :lg="12" class="mb20">
      <el-form-item ref="LinkedVM_Sn_FormItem" prop="LinkedVM.Sn" :label="$t('message.autotrans._Model_ProdArchiveData_Sn')"          :rules="[{required: true, message: $t('message._system.common.vm.input',{input:$t('message.autotrans._Model_ProdArchiveData_Sn')}), trigger: 'blur' }]" >
          <el-input v-model="stateProdArchiveData.vmModel.LinkedVM.Sn" clearable></el-input>
      </el-form-item>

      </el-col>
      <el-col :xs="24" :lg="12" class="mb20">
      <el-form-item ref="LinkedVM_Wo_FormItem" prop="LinkedVM.Wo" :label="$t('message.autotrans._Model_ProdArchiveData_Wo')">
          <el-input v-model="stateProdArchiveData.vmModel.LinkedVM.Wo" clearable></el-input>
      </el-form-item>

      </el-col>
      <el-col :xs="24" :lg="12" class="mb20">
      <el-form-item ref="LinkedVM_ProductId_FormItem" prop="LinkedVM.ProductId" :label="$t('message.autotrans._Model_ProdArchiveData_ProductId')"          :rules="[{required: true, message: $t('message._system.common.vm.input',{input:$t('message.autotrans._Model_ProdArchiveData_ProductId')}), trigger: 'blur' }]" >
          <el-input v-model="stateProdArchiveData.vmModel.LinkedVM.ProductId" clearable></el-input>
      </el-form-item>

      </el-col>
      <el-col :xs="24" :lg="12" class="mb20">
      <el-form-item ref="LinkedVM_ProductCode_FormItem" prop="LinkedVM.ProductCode" :label="$t('message.autotrans._Model_ProdArchiveData_ProductCode')">
          <el-input v-model="stateProdArchiveData.vmModel.LinkedVM.ProductCode" clearable></el-input>
      </el-form-item>

      </el-col>
      <el-col :xs="24" :lg="12" class="mb20">
      <el-form-item ref="LinkedVM_OpId_FormItem" prop="LinkedVM.OpId" :label="$t('message.autotrans._Model_ProdArchiveData_OpId')"          :rules="[{required: true, message: $t('message._system.common.vm.input',{input:$t('message.autotrans._Model_ProdArchiveData_OpId')}), trigger: 'blur' }]" >
          <el-input v-model="stateProdArchiveData.vmModel.LinkedVM.OpId" clearable></el-input>
      </el-form-item>

      </el-col>
      <el-col :xs="24" :lg="12" class="mb20">
      <el-form-item ref="LinkedVM_OpCode_FormItem" prop="LinkedVM.OpCode" :label="$t('message.autotrans._Model_ProdArchiveData_OpCode')">
          <el-input v-model="stateProdArchiveData.vmModel.LinkedVM.OpCode" clearable></el-input>
      </el-form-item>

      </el-col>
      <el-col :xs="24" :lg="12" class="mb20">
      <el-form-item ref="LinkedVM_DataTag_FormItem" prop="LinkedVM.DataTag" :label="$t('message.autotrans._Model_ProdArchiveData_DataTag')">
          <el-input v-model="stateProdArchiveData.vmModel.LinkedVM.DataTag" clearable></el-input>
      </el-form-item>

      </el-col>
      <el-col :xs="24" :lg="12" class="mb20">
      <el-form-item ref="LinkedVM_DataName_FormItem" prop="LinkedVM.DataName" :label="$t('message.autotrans._Model_ProdArchiveData_DataName')"          :rules="[{required: true, message: $t('message._system.common.vm.input',{input:$t('message.autotrans._Model_ProdArchiveData_DataName')}), trigger: 'blur' }]" >
          <el-input v-model="stateProdArchiveData.vmModel.LinkedVM.DataName" clearable></el-input>
      </el-form-item>

      </el-col>
      <el-col :xs="24" :lg="12" class="mb20">
      <el-form-item ref="LinkedVM_UpLimit_FormItem" prop="LinkedVM.UpLimit" :label="$t('message.autotrans._Model_ProdArchiveData_UpLimit')">
          <el-input v-model="stateProdArchiveData.vmModel.LinkedVM.UpLimit" clearable></el-input>
      </el-form-item>

      </el-col>
      <el-col :xs="24" :lg="12" class="mb20">
      <el-form-item ref="LinkedVM_DataValue_FormItem" prop="LinkedVM.DataValue" :label="$t('message.autotrans._Model_ProdArchiveData_DataValue')"          :rules="[{required: true, message: $t('message._system.common.vm.input',{input:$t('message.autotrans._Model_ProdArchiveData_DataValue')}), trigger: 'blur' }]" >
          <el-input v-model="stateProdArchiveData.vmModel.LinkedVM.DataValue" clearable></el-input>
      </el-form-item>

      </el-col>
      <el-col :xs="24" :lg="12" class="mb20">
      <el-form-item ref="LinkedVM_LowerLimit_FormItem" prop="LinkedVM.LowerLimit" :label="$t('message.autotrans._Model_ProdArchiveData_LowerLimit')">
          <el-input v-model="stateProdArchiveData.vmModel.LinkedVM.LowerLimit" clearable></el-input>
      </el-form-item>

      </el-col>
      <el-col :xs="24" :lg="12" class="mb20">
      <el-form-item ref="LinkedVM_SetParameter_FormItem" prop="LinkedVM.SetParameter" :label="$t('message.autotrans._Model_ProdArchiveData_SetParameter')">
          <el-input v-model="stateProdArchiveData.vmModel.LinkedVM.SetParameter" clearable></el-input>
      </el-form-item>

      </el-col>
    </el-row>

    <div style="text-align:right;">
      <WtmButton @click="onSubmitProdArchiveData"  type="primary" :button-text="$t('message.autotrans.SysSubmit')" style="margin-top:15px;"/>

      <WtmButton @click="onCloseProdArchiveData"  type="primary" :button-text="$t('message.autotrans.SysClose')" style="margin-top:15px;"/>

    </div>

  </el-form>

</el-card>
</div>
</template>


<script setup lang="ts" name="message.autotrans._PageProductionManagementProdArchiveDataBatchEdit;false">
import {  ElMessageBox, ElMessage,ElLoading } from 'element-plus';
import { defineAsyncComponent,reactive, ref, getCurrentInstance, onMounted, nextTick } from 'vue';
import { prodarchivedataApi } from '/@/api/productionmanagement/prodarchivedata';
import other from '/@/utils/other';
import fileApi from '/@/api/file';
import { useRouter } from "vue-router";
const ci = getCurrentInstance() as any;


// 定义变量内容
const formRefProdArchiveData = ref();
const stateProdArchiveData = reactive({
    vmModel: {
	  LinkedVM:{
        ArchiveIdId: null,
        Sn: '',
        Wo: '',
        ProductCode: '',
        OpCode: '',
        DataTag: '',
        DataName: '',
        DataValue: '',
        SetParameter: '',
      },
      Ids:[],
      
	},
    
    AllArchiveIds: [] as any[],
});

// 取消
const onCloseProdArchiveData = () => {
    closeDialog();
};

// 提交
const onSubmitProdArchiveData = () => {
	const loadingInstance = ElLoading.service({
		lock: true,
		text: '正在提交中，请等待。。。',
		background: 'rgba(0, 0, 0, 0.7)',
	});

    formRefProdArchiveData.value?.validate((valid: boolean, fields: any) => {
		if (valid) {
            prodarchivedataApi().batchedit(stateProdArchiveData.vmModel).then(() => {
                ElMessage.success(ci.proxy.$t('message._system.common.vm.submittip'));
                emit('refresh');
                closeDialog();
            }).catch((error:any) => {
                other.setFormError(ci, error);
            }).finally(() => {
			loadingInstance.close();
		    })
		}
        else{
			loadingInstance.close();
        }
	})
};


// 页面加载时
onMounted(() => {
    
    other.getSelectList('/api/ProductionManagement/ProdArchiveData/GetProdArchives',[],false).then(x=>{stateProdArchiveData.AllArchiveIds = x});
    if (ci.attrs["wtmdata"]) {
		stateProdArchiveData.vmModel.Ids = ci.attrs["wtmdata"];
	}
	else if (useRouter().currentRoute.value.query.id) {
		stateProdArchiveData.vmModel.Ids = useRouter().currentRoute.value.query.id as any;
	}

});

// 定义子组件向父组件传值/事件
const emit = defineEmits(['refresh','closeDialog']);
// 关闭弹窗
const closeDialog = () => {
    emit('closeDialog');
};
// 暴露变量
defineExpose({

});
</script>

<style scoped lang="scss">

</style>

